package com.panopset.game.blackjack;

import java.io.StringWriter;

import com.panopset.game.card.Shoe;

class CycleController {

    private Cycle cycle;
    private Cycle priorCycle;

    @Override
    public String toString() {
        StringWriter sw = new StringWriter();
        sw.append("cycle:" + cycle);
        sw.append(" prior cycle:" + priorCycle);
        return sw.toString();
    }
    public Cycle getCycle(BlackjackGame g, Shoe s) {
        if (cycle == null) {
            cycle = new Cycle(g, s);
        }
        return cycle;
    }

    public Cycle getPriorCycle() {
        return priorCycle;
    }

    public synchronized void reset() {
        priorCycle = cycle;
        cycle = null;
    }

    public boolean isDealt() {
        if (cycle == null) {
            return false;
        }
        return cycle.isDealt();
    }

    public boolean isActive() {
        if (cycle == null) {
            return false;
        }
        return cycle.isActive();
    }
}
